//
//  FLLInfoTableViewCell.m
//  FLLGodOfCooking
//
//  Created by LL.F on 16/9/12.
//  Copyright © 2016年 LL.F. All rights reserved.
//

#import "FLLInfoTableViewCell.h"
#import "FLLLikeCollectionViewCell.h"
#import "FLLMacro.h"

@interface FLLInfoTableViewCell ()<UICollectionViewDataSource, UICollectionViewDelegate, AutoLayoutDelegete>

@end
@implementation FLLInfoTableViewCell

- (void)awakeFromNib {
    // Initialization code
    
    [self createInfoCollectionView];
}
- (void)createInfoCollectionView
{

    self.autoLayout.delegate = self;
    
    self.autoCollectionView.delegate = self;
    self.autoCollectionView.dataSource = self;
    self.autoCollectionView.showsHorizontalScrollIndicator = NO;
    [self.autoCollectionView registerNib:[UINib nibWithNibName:@"FLLLikeCollectionViewCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"likeCollectionCell"];
    
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{

    if (_collectionArray.count != 0) {
        
        return 2;
    }
    return _collectionArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

    FLLLikeCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"likeCollectionCell" forIndexPath:indexPath];
    cell.titleLabel.text = _collectionArray[indexPath.row].text;
    cell.titleLabel.font = [UIFont systemFontOfSize:12 * kWidthScale];
    return cell;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout height:(CGFloat)height widthForItemAtIndexPath:(NSIndexPath *)indexPath {
    CGFloat width = [SelfSizeTool selfSizeWidthWithString:_collectionArray[indexPath.row].text height:height font:[UIFont systemFontOfSize:17]];
    // 给宽度取整
    return ceilf(width) + 10 * kWidthScale;
}
- (void)setCollectionArray:(NSMutableArray<InfoTags_Info *> *)collectionArray
{

    _collectionArray = collectionArray;
    [self.autoCollectionView reloadData];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
